
#ifndef __IOCP_EVENT_H__
#define __IOCP_EVENT_H__


#include "iocpdef.h"

#ifdef __cplusplus
extern "C" {
#endif

    IOEVENT * event_new(HIOCPBASE hIocp, DWORD dwFlag, PFN_EVENTPROC pfnCallBack, void * pUserData);
    BOOL event_assign(IOEVENT * pEvent, HIOCPBASE hIocp, DWORD dwFlag, 
        PFN_EVENTPROC pfnCallBack, void * pUserData);
    void event_free(IOEVENT * pEvent);

    int __stdcall event_binaryheap_cmp(void * pObject1, void * pObject2);
    void __stdcall event_update_index(void * pObject, unsigned int uIndex);

    void * event_get_userdata(IOEVENT * pEvent);
    void event_setfd(IOEVENT *pEvent, HIOCPFILE hObject);
    HIOCPFILE event_getfd(IOEVENT *pEvent);

    DWORD event_k2u_error(IOEVENT * pEvent);
    BOOL event_check_timeout(IOEVENT * pEvent, time_t tiCurrent);
    DWORD event_calc_timeout(IOEVENT * pEvent, time_t tiCurrent);

    BOOL event_add(IOEVENT * pEvent, DWORD dwTimeOut);
    BOOL event_del(IOEVENT * pEvent);

    BOOL event_set_timer(IOEVENT * pEvent);
    BOOL event_kill_timer(IOEVENT * pEvent);

    void event_push_reglist(IOEVENT * pEvent);
    void event_erase_reglist(IOEVENT * pEvent);

    BOOL event_cancelio(IOEVENT *pEvent);
    BOOL event_active(IOEVENT * pEvent, DWORD dwEvent);

    BOOL event_set_level(IOEVENT * pEvent, DWORD dwLevel);
    DWORD event_get_level(IOEVENT *pEvent);
    DWORD event_get_timeout(IOEVENT *pEvent);
#ifdef __cplusplus
};
#endif

#endif 